﻿<Window x:Class="UserNotification.View.SimpleNotificationWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"

        xmlns:Model="clr-namespace:UserNotification.ViewModel"
        xmlns:viewmodel="clr-namespace:UserNotification.ViewModel"
        xmlns:view="clr-namespace:UserNotification.View"
        xmlns:localiz="clr-namespace:UserNotification.Local"
        
        Title="Notifiactions"
        Focusable="False"
        ShowActivated="False"
        AllowsTransparency="True"
        WindowStyle="None"
        ShowInTaskbar="False"
        Background="Transparent"

        Topmost="{Binding IsTopmost}"
        MinWidth="350"
        MinHeight="75"
        SizeToContent="WidthAndHeight"
        ResizeMode="CanResize"
        >
  <Window.Resources>
    <Storyboard x:Key="CollapseStoryboard">
      <DoubleAnimation From="{Binding ViewHeight}" To="0" Storyboard.TargetProperty="Height" Duration="0:0:1"/>
    </Storyboard>
  </Window.Resources>

  <ContentControl x:Name="NotificationsControl" FocusVisualStyle="{x:Null}">
    <ContentControl.ContentTemplate>
      <DataTemplate DataType="Model:Notification">
        <Grid x:Name="NotificationWindow"
              Tag="{Binding Path=Id, NotifyOnTargetUpdated=True}"
              Background="Transparent"
              SizeChanged="NotificationWindowSizeChanged">
          <Border Name="border"
                  Background="{DynamicResource NotificationWindowBackground}"
                  BorderThickness="1"
                  BorderBrush="{DynamicResource NotificationWindowBorder}"
                  CornerRadius="2" Margin="10">
            <Border.Effect>
              <DropShadowEffect ShadowDepth="0" Opacity="0.8" BlurRadius="10"/>
            </Border.Effect>
            <Grid Margin="6" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"    />
              </Grid.RowDefinitions>
              <!-- Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
              </ -->

              <!-- Image Grid.RowSpan="2" Source="{Binding Path=ImageIcon}" Margin="3,3,12,3" Width="32"
                     VerticalAlignment="Top" HorizontalAlignment="Left" / -->

              <TextBlock Grid.Row="0"
                         Text="{Binding Path=Title}"
                         ToolTip="{Binding Path=Title}"
                         TextOptions.TextRenderingMode="ClearType"
                         TextOptions.TextFormattingMode="Display"
                         TextTrimming="CharacterEllipsis"
                         TextWrapping="NoWrap"
                         Foreground="{DynamicResource NotificationWindowForeground}" 
                         FontFamily="Arial"
                         FontSize="14"
                         FontWeight="Bold"
                         VerticalAlignment="Top"
                         HorizontalAlignment="Stretch"
                         Margin="2,4,4,2" />

              <!-- view:NotificationCloseButton x:Name="CloseButton" Grid.Column="1"
                                            ToolTip="{x:Static localiz:Strings.Close_Tip_Label}"
                                            Width="16" Height="16"
                                            HorizontalAlignment="Right" Margin="0,0,3,3" / -->

              <TextBlock Grid.Row="1"
                         Text="{Binding Path=Message}"
                         ToolTip="{Binding Path=Message}"
                         TextOptions.TextRenderingMode="ClearType"
                         TextOptions.TextFormattingMode="Display"                          
                         TextTrimming="CharacterEllipsis"
                         TextWrapping="WrapWithOverflow"
                         Foreground="{DynamicResource NotificationWindowForeground}" 
                         FontFamily="Arial"
                         VerticalAlignment="Stretch"
                         HorizontalAlignment="Stretch"
                         Margin="2,2,4,4"/>
            </Grid>
          </Border>
        </Grid>
        <DataTemplate.Triggers>
          <EventTrigger RoutedEvent="Binding.TargetUpdated" SourceName="NotificationWindow">
            <BeginStoryboard x:Name="FadeInStoryBoard">
              <Storyboard>
                <DoubleAnimation Storyboard.TargetName="NotificationWindow" From="0.90" To="1" Storyboard.TargetProperty="Opacity" Duration="0:0:2"/>
                <DoubleAnimation Storyboard.TargetName="NotificationWindow" From="1" To="0" Storyboard.TargetProperty="Opacity" Duration="0:0:2" BeginTime="0:0:6"/>
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
          <!-- Trigger Property="IsMouseOver" Value="True">
            <Trigger.EnterActions>
              <SeekStoryboard Offset="0:0:3" BeginStoryboardName="FadeInStoryBoard" />
              <PauseStoryboard BeginStoryboardName="FadeInStoryBoard" />
            </Trigger.EnterActions>
            <Trigger.ExitActions>
              <SeekStoryboard Offset="0:0:3" BeginStoryboardName="FadeInStoryBoard" />
              <ResumeStoryboard BeginStoryboardName="FadeInStoryBoard"></ResumeStoryboard>
            </Trigger.ExitActions>
          </Trigger -->
          <!-- EventTrigger RoutedEvent="Button.Click" SourceName="CloseButton">
            <BeginStoryboard>
              <Storyboard >
                <DoubleAnimation Storyboard.TargetName="NotificationWindow" From="1" To="0" Storyboard.TargetProperty="(Grid.Opacity)" Duration="0:0:0"/>
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger -->
          <Trigger SourceName="NotificationWindow" Property="Opacity" Value="0">
            <Setter TargetName="NotificationWindow" Property="Visibility" Value="Hidden"></Setter>
            <!-- Trigger.EnterActions>
              <BeginStoryboard Storyboard="{StaticResource CollapseStoryboard}"/>
            </Trigger.EnterActions -->
          </Trigger>
        </DataTemplate.Triggers>
      </DataTemplate>

    </ContentControl.ContentTemplate>
  </ContentControl>
</Window>
